#ifndef ROCKET_NET_IO_THREAD_H
#define ROCKET_NET_IO_THREAD_H

#include <pthread.h>
#include <semaphore.h>

#include "eventloop.h"

namespace rocket {

class IOThread {

  public:
    IOThread();

    ~IOThread();

    EventLoop *getEventLoop();

    void join();

    void start();

  public:
    static void *Main(void *arg);

  private:
    pid_t m_thread_id{-1};
    pthread_t m_thread{0};

    EventLoop *m_event_loop{nullptr};

    sem_t m_init_semaphore;
    sem_t m_start_semaphore;
};

} // namespace rocket

#endif
